CC=gcc ${DEBUG}
CFLAGS=-c -Wall
LDFLAGS=-Wall
OBJS=asm.o err.o func.o init.o lex.o main.o opers.o run.o rutree.o sem.o syn.o textp.o type.o var.o
SAMPLES=arr.out ch.out dbr.out kef.out let.out nj.out recu.out ref.out sample.out stru.out sud.out
SAMPASM=arr.asm ch.asm dbr.asm kef.asm let.asm nj.asm recu.asm ref.asm sample.asm stru.asm sud.asm

.SECONDARY: ${OBJS}

all: myc

myc: ${OBJS}
	${CC} ${LDFLAGS} -o myc ${OBJS}

%.o: src/%.c src/myc.h
	$(CC) $(CFLAGS) $< -o $@

test: ${SAMPLES} ${SAMPASM}

%.out: %.aso asm/com.aso
	ld $< asm/com.aso -o $@

%.aso: %.asm
	nasm -f elf64 $< -o $@

%.asm: samples/%.myc myc
	./myc $< -o $@
	
clean:
	rm -f *.o *.out *.asm myc
